[Zend Framework] Forms and success output
Posted
by rasouza
on Stack Overflow
See other posts from Stack Overflow
or by rasouza
Published on 2010-05-16T05:07:18Z
Indexed on
2010/05/16
5:10 UTC
Read the original article
Hit count: 159
Well,
It's a beginer's question but I really don't know what is the best way. I have a basic CRUD (Create, Retrieve, Update and Delete) in my project and I'd like to output some message if succeded or not in a div inside the same page.
So, basically, I have a form which action is setted to the same page and I have a div #statusDiv below this same form which I'd like to output something like Register included with success.
What is the best way for doing this?
- Set a flag in the controller
$this->view->flagStatus = 'message'
then call it in the view?
Just to make it more clear. It's my code:
//IndexController.php indexAction()
...
//Check if there's submitted data
if ($this->getRequest()->isPost()) {
...
$registries->insert($data);
$this->view->flagStatus = 'message';
$this->_redirect('/');
}
Then my view:
....
<?php if ($this->flagStatus) { ?>
<div id="divStatus" class="success span-5" style="display: none;">
<?php echo $this->flagStatus; ?>
</div>
<?php } ?>
....
© Stack Overflow or respective owner